<?php
/*::::::::::::::::::::::::::::::::::::::::
 System name: cpengine
 Short Desc: Full Russian Security Power Pack
 Version: 2.0 (Service Pack 2)
 Authors:  Arcanum (php@211.ru) &  Censored!
 Date: March 18, 2008
::::::::::::::::::::::::::::::::::::::::*/

class titles {

  function titlesList($tpl_dir, $lang_file)
  {
  	global $AVE_DB, $AVE_Template;
  	$AVE_Template->config_load($lang_file);
    $titles = array();
    $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_modul_titles");
    while ($result = $sql->fetchrow()) {
      $result->tag = "[titles:" . $result->id . "]";
      array_push($titles, $result);
    }

    $AVE_Template->assign("titles", $titles);
    $AVE_Template->assign("content", $AVE_Template->fetch($tpl_dir . "titles_list.tpl"));
  }

  function titlesAdd()
  {
  	  global $AVE_DB;
    $url = addslashes(htmlspecialchars($_POST['url']));
    $title = addslashes(htmlspecialchars($_POST['title']));   
    $keywords = addslashes(htmlspecialchars($_POST['keywords'])); 
    $description = addslashes(htmlspecialchars($_POST['description']));      
    
    $AVE_DB->Query("INSERT INTO " . PREFIX . "_modul_titles(`url`, `title`, `keywords`, `description`) VALUES ('".$url."', '".$title."', '". $keywords ."', '" . $description . "')");
    header("Location:index.php?do=modules&action=modedit&mod=titles&moduleaction=1&cp=" . SESSION);
  }

  function titlesDelete()
  {
  	  global $AVE_DB;
    $id = addslashes($_GET['id']);
    $AVE_DB->Query("DELETE FROM " . PREFIX . "_modul_titles WHERE id = '" . $id . "'");
    header("Location:index.php?do=modules&action=modedit&mod=titles&moduleaction=1&cp=" . SESSION);
  }

  function titleEdit($tpl_dir, $lang_file)
  {
  	  global $AVE_DB, $AVE_Template;
  	  $AVE_Template->config_load($lang_file);
  	  
    $id = (int)($_GET['id']);
    $titles = array();
    $sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_modul_titles WHERE `id` = " . $id);
    while ($result = $sql->fetchrow()) {
      $result->tag = "[titles:" . $result->id . "]";
      array_push($titles, $result);
    }

    $AVE_Template->assign("title_id", $id);
    $AVE_Template->assign("titles", $titles);
    $AVE_Template->assign("content", $AVE_Template->fetch($tpl_dir . "titles_edit.tpl"));
  }

  function titlesSave()
  {
  	  global $AVE_DB;
    $id        = (int)$_GET['id'];
    $url = addslashes(htmlspecialchars($_POST['url']));
    $title = addslashes(htmlspecialchars($_POST['title']));   
    $keywords = addslashes(htmlspecialchars($_POST['keywords'])); 
    $description = addslashes(htmlspecialchars($_POST['description']));  
    
    $AVE_DB->Query("UPDATE " . PREFIX . "_modul_titles
      SET
        url = '" . $url . "',
        keywords = '" . $keywords . "',
        description = '" . $description . "',
        title = '" . $title . "'
      WHERE
        id = '" . $id . "'
      ");
    header("Location:index.php?do=modules&action=modedit&mod=titles&moduleaction=1&cp=" . SESSION);
  }
}
?>